﻿using System;
using System.Data;
using System.Collections.Generic;
using ChinaSoft.Common;
using ChinaSoft.Model;
namespace ChinaSoft.BLL
{
	/// <summary>
	/// 系统日志
	/// </summary>
	public partial class BLL_T_SYS_LOGS
	{
		private readonly ChinaSoft.DAL.DAL_T_SYS_LOGS dal=new ChinaSoft.DAL.DAL_T_SYS_LOGS();
		public BLL_T_SYS_LOGS()
		{}
		#region  Method
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string SYS_LOGS_ID)
		{
			return dal.Exists(SYS_LOGS_ID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public bool Add(ChinaSoft.Model.Model_T_SYS_LOGS model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(ChinaSoft.Model.Model_T_SYS_LOGS model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(string SYS_LOGS_ID)
		{
			
			return dal.Delete(SYS_LOGS_ID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string SYS_LOGS_IDlist )
		{
			return dal.DeleteList(SYS_LOGS_IDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public ChinaSoft.Model.Model_T_SYS_LOGS GetModel(string SYS_LOGS_ID)
		{
			
			return dal.GetModel(SYS_LOGS_ID);
		}

		/// <summary>
		/// 得到一个对象实体，从缓存中
		/// </summary>
		public ChinaSoft.Model.Model_T_SYS_LOGS GetModelByCache(string SYS_LOGS_ID)
		{
			
			string CacheKey = "Model_T_SYS_LOGSModel-" + SYS_LOGS_ID;
			object objModel = ChinaSoft.Common.DataCache.GetCache(CacheKey);
			if (objModel == null)
			{
				try
				{
					objModel = dal.GetModel(SYS_LOGS_ID);
					if (objModel != null)
					{
						int ModelCache = ChinaSoft.Common.ConfigHelper.GetConfigInt("ModelCache");
						ChinaSoft.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
					}
				}
				catch{}
			}
			return (ChinaSoft.Model.Model_T_SYS_LOGS)objModel;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_T_SYS_LOGS> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<ChinaSoft.Model.Model_T_SYS_LOGS> DataTableToList(DataTable dt)
		{
			List<ChinaSoft.Model.Model_T_SYS_LOGS> modelList = new List<ChinaSoft.Model.Model_T_SYS_LOGS>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				ChinaSoft.Model.Model_T_SYS_LOGS model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new ChinaSoft.Model.Model_T_SYS_LOGS();
					if(dt.Rows[n]["SYS_LOGS_ID"]!=null && dt.Rows[n]["SYS_LOGS_ID"].ToString()!="")
					{
					model.SYS_LOGS_ID=dt.Rows[n]["SYS_LOGS_ID"].ToString();
					}
					if(dt.Rows[n]["OPERATORID"]!=null && dt.Rows[n]["OPERATORID"].ToString()!="")
					{
					model.OPERATORID=dt.Rows[n]["OPERATORID"].ToString();
					}
					if(dt.Rows[n]["OPERATORNAME"]!=null && dt.Rows[n]["OPERATORNAME"].ToString()!="")
					{
					model.OPERATORNAME=dt.Rows[n]["OPERATORNAME"].ToString();
					}
					if(dt.Rows[n]["OPERATORIP"]!=null && dt.Rows[n]["OPERATORIP"].ToString()!="")
					{
					model.OPERATORIP=dt.Rows[n]["OPERATORIP"].ToString();
					}
					if(dt.Rows[n]["OPERATIONCODE"]!=null && dt.Rows[n]["OPERATIONCODE"].ToString()!="")
					{
					model.OPERATIONCODE=dt.Rows[n]["OPERATIONCODE"].ToString();
					}
					if(dt.Rows[n]["OPERATEENTITY"]!=null && dt.Rows[n]["OPERATEENTITY"].ToString()!="")
					{
					model.OPERATEENTITY=dt.Rows[n]["OPERATEENTITY"].ToString();
					}
					if(dt.Rows[n]["OPERATETIME"]!=null && dt.Rows[n]["OPERATETIME"].ToString()!="")
					{
						model.OPERATETIME=DateTime.Parse(dt.Rows[n]["OPERATETIME"].ToString());
					}
					if(dt.Rows[n]["CONTENT"]!=null && dt.Rows[n]["CONTENT"].ToString()!="")
					{
					//model.CONTENT=dt.Rows[n]["CONTENT"].ToString();
					}
					if(dt.Rows[n]["LOGINNAME"]!=null && dt.Rows[n]["LOGINNAME"].ToString()!="")
					{
					model.LOGINNAME=dt.Rows[n]["LOGINNAME"].ToString();
					}
					if(dt.Rows[n]["OPERATORAREAID"]!=null && dt.Rows[n]["OPERATORAREAID"].ToString()!="")
					{
						model.OPERATORAREAID=decimal.Parse(dt.Rows[n]["OPERATORAREAID"].ToString());
					}
					if(dt.Rows[n]["OP_AREA"]!=null && dt.Rows[n]["OP_AREA"].ToString()!="")
					{
					model.OP_AREA=dt.Rows[n]["OP_AREA"].ToString();
					}
					if(dt.Rows[n]["MODULENAME"]!=null && dt.Rows[n]["MODULENAME"].ToString()!="")
					{
					model.MODULENAME=dt.Rows[n]["MODULENAME"].ToString();
					}
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public int GetRecordCount(string strWhere)
		{
			return dal.GetRecordCount(strWhere);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
		{
			return dal.GetListByPage( strWhere,  orderby,  startIndex,  endIndex);
		}
		/// <summary>
		/// 分页获取数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  Method
	}
}

